package com.jtpay.textpay.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class PayDataHelper extends SQLiteOpenHelper {
    private static final String SQL_CREATE_TABLE = "CREATE TABLE ";
    private static final String DATABASE_NAME = "appid_product.db";
    private static final String SQL_AUTOINCREMENT_KEY = " INTEGER PRIMARY KEY AUTOINCREMENT";
    private static final String SQL_COMMA = ",";
    private static final String SQL_TEXT = " TEXT";
    private static final String SQL_TEXT_PRIMARY_KEY = " TEXT UNIQUE";
    private static final int VERSION = 1;
    private String createTablePayParams = SQL_CREATE_TABLE +AppidColumns.TABLE_NAME_PAY
            + " (" + AppidColumns._ID + SQL_AUTOINCREMENT_KEY + SQL_COMMA
            + AppidColumns.APPID + SQL_TEXT_PRIMARY_KEY + SQL_COMMA
            + AppidColumns.APP_KEY + SQL_TEXT + SQL_COMMA
            + AppidColumns.AES_KEY + SQL_TEXT + SQL_COMMA
            + AppidColumns.AES_VECTOR + SQL_TEXT
            + ");";
    PayDataHelper(Context context) {
        super(context, DATABASE_NAME, null, VERSION);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(createTablePayParams);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (newVersion != VERSION) {
            return;
        }
        switch (oldVersion) {
            case 1:
                db.execSQL(createTablePayParams);
                break;
            default:
                break;
        }
    }
}
